First, import and tidy data:
gender neighborhood VS hiv
neb_plot = hiv_data %>%
group_by(neighborhood, gender) %>%
filter(age != "All") %>%
summarise(sum_hiv = sum(hiv_diagnoses)) %>%
ggplot(aes(x = reorder(neighborhood, sum_hiv), y = sum_hiv, color = gender)) +
coord_flip() +
geom_point() +
labs(
title = "Gender and Neighborhood Influence on HIV Incidence",
x = "Neighborhood",
y = "HIV diagnoses",
caption = "Data from the ..."
)
ggplotly(neb_plot)
The number of HIV diagnoses is higher among male than female in all neighborhoods. Beford Stuyvesant - Crown Heights have the most HIV diagnoses for both men and women.
gender, age vs hiv
age_plot = hiv_data %>%
filter(age != "All") %>%
group_by(gender, age) %>%
summarise(sum_hiv = sum(hiv_diagnoses)) %>%
ggplot(aes(y = sum_hiv, x = age, fill = gender)) +
geom_bar(stat = "identity", alpha = 0.8, position = position_dodge()) +
scale_fill_brewer(palette = "Dark2") +
labs(
title = "Gender and Age Influence on HIV Incidence",
x = "Age range",
y = "HIV diagnoses",
caption = "Data from the ..."
)
ggplotly(age_plot)
age_plot2 = hiv_data2 %>%
filter(borough == "All", neighborhood == "All", race == "All", gender != "All", age != "All") %>%
group_by(gender, age) %>%
summarise(sum_hiv = sum(hiv_diagnoses)) %>%
ggplot(aes(y = sum_hiv, x = age, fill = gender)) +
geom_bar(stat = "identity", alpha = 0.8, position = position_dodge()) +
scale_fill_brewer(palette = "Dark2") +
labs(
title = "Gender and Age Influence on HIV Incidence",
x = "Age range",
y = "HIV diagnoses",
caption = "Data from the ..."
)
ggplotly(age_plot2)
gender race vs hiv
race_plot = hiv_data %>%
filter(race != "All") %>%
group_by(gender, race) %>%
summarise(sum_hiv = sum(hiv_diagnoses)) %>%
ggplot(aes(y = sum_hiv, x = reorder(race, sum_hiv), fill = gender)) +
geom_bar(stat = "identity", alpha = 0.8, position = position_dodge()) +
scale_fill_manual(values = c("#E69F00", "#56B4E9")) +
labs(
title = "Race and Gender Influence on HIV Incidence",
x = "Race",
y = "HIV diagnoses",
caption = "Data from the ..."
)
ggplotly(race_plot)
race_plot2 = hiv_data2 %>%
filter(borough == "All", neighborhood == "All", race != "All", gender != "All", age == "All") %>%
group_by(gender, race) %>%
summarise(sum_hiv = sum(hiv_diagnoses)) %>%
ggplot(aes(y = sum_hiv, x = reorder(race, sum_hiv), fill = gender)) +
geom_bar(stat = "identity", alpha = 0.8, position = position_dodge()) +
scale_fill_manual(values = c("#E69F00", "#56B4E9")) +
labs(
title = "Race and Gender Influence on HIV Incidence",
x = "Race",
y = "HIV diagnoses",
caption = "Data from the ..."
)
ggplotly(race_plot2)
hiv diagnoses in borough with most hiv over years
hiv_data2 %>%
filter(borough != "All", neighborhood == "All", gender == "All", age == "All", race == "All") %>%
group_by(borough) %>%
summarize(sum_hiv = sum(hiv_diagnoses)) %>%
arrange(desc(sum_hiv))
## # A tibble: 5 x 2
## borough sum_hiv
## <chr> <int>
## 1 Brooklyn 3815
## 2 Manhattan 3536
## 3 Bronx 2736
## 4 Queens 2327
## 5 Staten Island 217
year_plot = hiv_data %>%
mutate(year = as.integer(year)) %>%
filter(borough == "Brooklyn" & gender == "Male" & age == "20 - 29") %>%
group_by(year, neighborhood) %>%
summarize(sum_hiv = sum(hiv_diagnoses)) %>%
ggplot(aes(x = year, y = sum_hiv, color = neighborhood)) +
geom_line()
ggplotly(year_plot)
Limitations:
We can not visualize the effect of age and race at the same time.